﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;

namespace DATN.mds.Product
{
    public partial class CreateProduct : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                string name = TextBox1.Text;
                decimal price = Convert.ToDecimal(TextBox2.Text);
                string id = Session["Us_Id"].ToString();
                string descrip = TextBox3.Text;
                SqlConnection cnn = new SqlConnection();
                cnn.ConnectionString = ConfigurationManager.ConnectionStrings["DATNconnection"].ToString();
                SqlCommand cmd = cnn.CreateCommand();

                string com1 = "Insert into Products (Name, Describe, Price, Us_Id)" +
                    "" + "values(N'" + name + "',N'" + descrip + "','" + price +"','"+ id+"')";
                
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = com1;


                cnn.Open();
                cmd.ExecuteNonQuery();
                cnn.Close();
                Page.Response.Redirect("~/mds.Product/ProductIndext.aspx");
            }
        }
    }
}